Skip to main content

Cassandra

Query Overview

For more information on the Cassandra Query Language (CQL), see

and

Per the DataStax cassandra-driver authors guidance, only use one Client instance per keyspace or use a single Client and explicitly specify the keyspace in your queries. For other guidance see

Note that “DESCRIBE TABLES” and other similar requests are cqlsh commands, not CQL queries. It works in the Cassandra shell and many Cassandra-compatible GUIs, but not via the standard CQL Node.js driver.

Data Type Handling

A discussion on mapping JavaScript data types to CQL data types is at
https://docs.datastax.com/en/developer/nodejs-driver/4.7/features/datatypes/index.html

Consider a table defined using the following statements.

// Create a UDT for nested address info
CREATE TYPE IF NOT EXISTS address (
street text,
city text,
zip int
)
CREATE TABLE IF NOT EXISTS complex_items (
id UUID PRIMARY KEY,
name TEXT,
age INT,
scores LIST<FLOAT>,
tags SET<TEXT>,
attributes MAP<TEXT, TEXT>,
created_at TIMESTAMP,
active BOOLEAN,
address FROZEN<address>
)

In the query tools the schema would be represented as shown below.

  



  

A simple query is

select * from complex_items limit 1

A sample result is shown below.

  

The details of the row are shown below.

  

Notice that the complex data structure is maintained and values are appropriate even the TIMESTAMP created_at column value. With Qarbine, there is no “flattening” or any convoluted data gymnastics needed from legacy SQL-centric approaches.

Keyspace Context

The Qarbine data service configuration may optionally specify a keyspace. When this is done the query context is within that keyspace. When a keyspace is not set then keep the following guidelines in mind:

  • Unquoted keyspace names are considered lowercase in Cassandra.
  • Use lowercase in queries or quote the name if created with mixed case.

Consider a keyspace named “myKeyspace”. Note that the case is mixed. This query

select * from myKeyspace.complex_items limit 1

results in

{"error":"Cassandra 1.0 error keyspace mykeyspace does not exist"}

This query

select * from "myKeyspace".complex_items limit 1

results in

  

Troubleshooting

DataStax Astra

Because Astra DB Serverless is powered by Apache Cassandra®, you can use Cassandra Query Language (CQL) to programmatically interact with your databases through the CQL shell. Information on running the CQL shell with DataStax is located at
https://docs.datastax.com/en/astra-db-serverless/databases/connection-methods-comparison.html#cql-shell

Azure Managed Cassandra

Azure Cosmos DB Data Explorer is a web-based interface that allows you to view and manage the data stored in Azure Cosmos DB. The dedicated Azure Cosmos DB Data Explorer (https://cosmos.azure.com). For more details see

For operational issues see the guides at
https://learn.microsoft.com/en-us/azure/cosmos-db/cassandra/troubleshoot-common-issues

and
https://learn.microsoft.com/en-us/azure/cosmos-db/cassandra/error-codes-solution

AWS Keyspaces

See the following link for general Keyspace console access
https://docs.aws.amazon.com/keyspaces/latest/devguide/console_keyspaces.html

and this link for information on using cqlsh to access Keyspaces
https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.cqlsh.html

ScyllaDB

A ScyllaDB reference for CQL can be found at

Information on using csqlsh with ScyllaDB can be found at

General information on troubleshooting ScyllaDB can be found at